import random
import pymysql
# encoding: utf-8
# 省份地市区县经度纬度
# 山西省太原市太原市112.55  37.87
# 山西省太原市小店区112.57  37.73
# 山西省太原市迎泽区112.57   37.87
# 山西省太原市杏花岭区112.57  37.88
# 山西省太原市尖草坪区112.48  37.93
# 山西省太原市万柏林区112.52  37.87
# 山西省太原市晋源区112.48  37.73


"""
a = "小店区"  b = "迎泽区"  c = "杏花岭区"  d = "尖草坪区"  e = "万柏林区"  f = "晋源区"

"""

# l1 = ['%0.5f' % random.uniform(112.55, 112.563) for i in range(200)]
# # print(l1)
# l2 = ['%0.5f' % random.uniform(37.73, 37.87) for i in range(200)]
# # print(l2)
# a = "小店区"


# l1 = ['%0.5f' % random.uniform(112.55, 112.567) for i in range(128)]
#
# l2 = ['%0.5f' % random.uniform(37.87, 37.875) for i in range(128)]
# b = "迎泽区"
#
# l1 = ['%0.5f' % random.uniform(112.55, 112.569) for i in range(258)]
#
# l2 =['%0.5f' % random.uniform(37.875, 37.88) for i in range(258)]
# c = "杏花岭区"

# l1 = ['%0.5f' % random.uniform(112.48, 112.55) for i in range(98)]
#
# l2 = ['%0.5f' % random.uniform(37.881, 37.93) for i in range(98)]
# d = "尖草坪区"
#
# l1 = ['%0.5f' % random.uniform(112.52, 112.55) for i in range(166)]
#
# l2 = ['%0.5f' % random.uniform(37.875, 37.879) for i in range(166)]
# e = "万柏林区"
#
l1 = ['%0.5f' % random.uniform(112.485, 112.55) for i in range(123)]

l2 = ['%0.5f' % random.uniform(37.73, 37.83) for i in range(123)]
f = "晋源区"


# for i in range(111.30, 113.09):
#     print('%04.3f' %  % random.random())

conn = pymysql.connect(host='127.0.0.1', port=3306, user='root', passwd='mysql',db='ck_iot_B')
cur = conn.cursor()
for i in range(len(l1)):   #插入数据
  lng=random.choice(l1)
  lat = random.choice(l2)  # 在纬度列表中随机取一个
  cur.execute("insert into point(lng,lat,dis_name) values(%s,%s,%s)",(lng,lat,f))#注意用法
cur.execute('select * from point') #查询数据
for s in cur.fetchall():
  print(s)
conn.commit()
cur.close()










